home *** CD-ROM | disk | FTP | other *** search
- Path: kettle.magna.com.au!news
- From: peter@magna.com.au
- Newsgroups: comp.lang.c++
- Subject: Re: STL deque compile warning
- Date: 11 Jan 1996 14:33:08 GMT
- Organization: MAGNADATA Internet Services
- Message-ID: <4d3734$mdc@kettle.magna.com.au>
- References: <4cvf0n$jq@maureen.teleport.com>
- NNTP-Posting-Host: enterprise.magna.com.au
- X-Newsreader: AIR News 3.X (SPRY, Inc.)
-
- > Jeff Grossman <grossman@teleport.com> writes:
- > Using MSVC4 (and the STL on MS's CD-ROM), this simple program,
- >
- > #include <deque.h>
- >
- > class foo
- > {
- > int n1;
- > int n2;
- > };
- >
- > int main ()
- > {
- > deque< foo > dFoo;
- >
- > return 0;
- > }
- >
- >
- > generates the following warnings:
- >
- > deque.h(106) : warning C4146: unary minus operator applied to
- > unsigned type, result still unsigned
- > deque.h(187) : warning C4146: unary minus operator applied to
- > unsigned type, result still unsigned
- > deque.h(455) : warning C4018: '>' : signed/unsigned mismatch
- > deque.h(469) : warning C4018: '>' : signed/unsigned mismatch
- >
- >
- > Does anyone know STL well enough to understand the significance of these
- > warnings?
- >
- > I've looked at the offending code, but I'm very new to STL, and I can't
- > tell if these warnings are indicative of a true problem or not.
- >
- >
- > TIA,
- > Jeff
- >
-
- I'm only just starting on STL so here goes my $0.02.
-
- line 106 warning refers to the following
-
- difference_type num_node_to_jump = offset >= 0
- ? offset / buffer_size
- : -((-offset + buffer_size - 1) / buffer_size);
-
- where
- typedef int ptrdiff_t; // from <stddef.h>
-
- typedef ptrdiff_t difference_type; // from <stl\defalloc.h>
-
- difference_type offset;
- size_t buffer_size; // which is an unsigned from <stddef.h>
-
- Now the result of the offset + buffer_size goes through *integral promotion* (ARM 4.1).
- The result of unary negation of the unsigned is still an unsigned.
-
- Ditto line 187.
-
- Line 455 refers to
-
- if (n > position - old_begin)
-
- where
- size_t n; // hence an unsigned.
- iterator position;
- iterator old_begin;
-
- now the result of position - old_begin must convert to an int (signed).
-
- I do not know if iterator is signed (being a pointer I would think that it is
- unsigned), or if the result of subtraction of two unsigned values converts
- to an int.
-
-
- I did also compile your test program using the STL<ToolKit> from
- ObjectSpace and it did not have any problem.
-
- Hope this helps a little.
-
- Cheers,
- Peter J Brock
-
-